package ch.selise.exercise.pattern.notepad.storage;

import java.util.ArrayList;
import java.util.List;

public class AppStorageSingleton {
	private List<String> text = new ArrayList<String>();
	//private List<ICommand> commands = new ArrayList<ICommand>();
	//private List<ICommand> undoCommands = new ArrayList<ICommand>();

	private static AppStorageSingleton instance;

	public static AppStorageSingleton getInstance() {
		if (instance == null) {

			instance = new AppStorageSingleton();
		}
		return instance;
	}

	public int addText(String text) {
		// System.out.println("adding text..");
		this.text.add(text);
		return this.text.size() - 1;
	}

	public void removeText(int index) {
		// this.text.remove()
		// System.out.println("removing text..");
		text.remove(index);
	}

	public List<String> getText() {
		// System.out.println("returning text.");
		return text;
	}

	/*public void addCommand(ICommand command) {
		commands.add(command);
	}

	public IUndoableCommand undoCommand() throws EmptyStackException {
		try {
			ICommand undo = commands.remove(commands.size() - 1);
			undoCommands.add(undo);
			return (IUndoableCommand) undo;
		} catch (Exception e) {
			throw new EmptyStackException("Command Stack is empty", e);
		}
	}

	public IUndoableCommand redoCommand() throws EmptyStackException {
		try {
			ICommand redo = undoCommands.remove(undoCommands.size() - 1);
			commands.add(redo);
			return (IUndoableCommand) redo;
		} catch (Exception e) {
			throw new EmptyStackException("Undo Command Stack is empty", e);
		}
	}*/

}
